from kubernetes import client, config
config.kube_config.load_kube_config(config_file="../kubeconf.yaml")

v1 = client.CoreV1Api()

def todict(obj, classkey=None):
    if isinstance(obj, dict):
        data = {}
        for (k, v) in obj.items():
            data[k] = todict(v, classkey)
        return data
    elif hasattr(obj, "_ast"):
        return todict(obj._ast())
    elif hasattr(obj, "__iter__"):
        return [todict(v, classkey) for v in obj]
    elif hasattr(obj, "__dict__"):
        data = dict([(key, todict(value, classkey))
                     for key, value in obj.__dict__.__iter__()
                     if not callable(value) and not key.startswith('_')])
        if classkey is not None and hasattr(obj, "__class__"):
            data[classkey] = obj.__class__.__name__
        return data
    else:
        return obj

rets = v1.read_namespaced_pod(name="kubia-manual", namespace="default").__dict__

# print(rets)
# for k, v in enumerate(rets):
#     print(v)
# print(type(rets['_spec']))
status = rets['_status'].__dict__
# for k, v in enumerate(status):
#     print(v)
condition = status['_conditions']
print(type(condition[0]))


